import { WebGLRenderer, Color } from 'three'

function createRenderer ({ canvas, width = 800, height = 600, bgcolor = '#35415E', bgalpha = 1 } = {}) {
    const renderer = new WebGLRenderer({
        canvas,
        antialias: true,
        preserveDrawingBuffer: true,
        alpha: true
    })

    renderer.setPixelRatio(window.devicePixelRatio)
    renderer.setSize(width, height)
    renderer.setClearColor(new Color(bgcolor), Number(bgalpha))
    renderer.shadowMap.enabled = true

    renderer.localClippingEnabled = true

    return renderer
}

export {
    createRenderer
}
